import toml
import os


class Config:
    def __init__(self):
        config_path = f"{os.getcwd()}/config/config.toml"
        print(f"config path: {config_path}")
        with open(config_path, 'r') as f:
            c = toml.load(f)
        print(f'load config success: {c}')
        self.ray_endpoint = c.get("ray", {}).get("endpoint", os.environ.get('RAY_ENDPOINT', "ray://10.130.9.3:10001"))

        self.res_endpoint = c.get("res", {}).get("uri", os.environ.get('RES_URI', ""))
        self.bdf_op2_endpoint = c.get("bdf_op2_structure", {}).get("uri", os.environ.get('RES_URI', ""))

        self.db_host = c.get("db", {}).get("host", "")
        self.db_port = c.get("db", {}).get("port", 30105)
        self.db_user = c.get("db", {}).get("user", "psotgres")
        self.db_password = c.get("db", {}).get("password", "")
        self.db_dbname = c.get("db", {}).get("dbname", "sh_sim_structure")

        self.oss_type = c.get("oss", {}).get("type", "minio")
        self.oss_endpoint = c.get("oss", {}).get("endpoint", "")
        self.oss_access_key = c.get("oss", {}).get("access_key", "")
        self.oss_secret_key = c.get("oss", {}).get("secret_key", "")
        self.oss_secure = c.get("oss", {}).get("secure", False)
        self.oss_bucket = c.get("oss", {}).get("bucket", "sh-dc")

        self.data_engine_endpoint = c.get("data_engine", {}).get("endpoint")
        self.data_engine_api_token = c.get("data_engine", {}).get("api_token")


config = Config()
